package com.csun.cmny.provider.device.watch.entity;

    /// <summary>
    ///  下行确认位置数据包
    ///  关联 上行001
    /// Tunneling confirmation location data package
    ///Association  command  FunCode: 001
    /// </summary>
    public class C002
    {
        /// <summary>
        /// 数据起封包 @B#@ 
        /// Start Fixed value :@B#@ 
        /// </summary>
        public String HeadCode = "@B#@";
        /// <summary>
        /// 协议版本号
        /// Protocol version number
        /// </summary>
        public String Protocol = null;

        /// <summary>
        /// 功能代码识别
        /// Function code
        /// </summary>
        public final String FunCode = "002";
        /// <summary>
        /// 国际移动设备身份码
        /// International Mobile Equipment Identity
        /// </summary>
        public String IMEI = null;
        /// <summary>
        /// 数据状态 0：结束 1：继续接受
        /// Data state 0: end; 1: continue to accept
        /// </summary>
        public int DataState =0;
        /// <summary>
        /// 终端当前时间(年月日时分秒) yyyyMMddHHmmss
        /// The terminal current time ( format:yyyyMMddHHmmss)
        /// </summary>
        public String TerminalTime = null;
        /// <summary>
        /// 结尾封包 @E#@
        /// End packet @E#@
        /// </summary>
        public String FootCode = "@E#@";

        public C002(){}

        /// <summary>
        /// 初始化模型
        /// @B#@|01|002|111112222233333|0|20160729173850|@E#@
        /// </summary>
        /// <param name="cmdStr">命令代码</param>
        public C002(String cmdStr)
        {
            String[] data = cmdStr.split("\\|");
            int dataLength = data.length;
            if (dataLength ==7 && data[0] == "@B#@" && FunCode == data[2])
            {
                HeadCode = data[0];
                Protocol = data[1];
                IMEI = data[3];
                DataState = Integer.parseInt(data[4]);
                TerminalTime = data[5];
                FootCode = data[6];
            }

        }



        public  String ToString()
        {
            String rString = HeadCode + "|";
            rString += Protocol + "|";
            rString += FunCode + "|";
            rString += IMEI + "|";
            rString += DataState + "|";
            rString += TerminalTime + "|";
            rString += FootCode;
            return rString;
        }
    }



